# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 0
n 0(None)[Container.__init__(self)
self._bar_name = None
self._indicator_name = None
self._timeshift_bar_name = None
self._live = 0
self._direct = 100
self._timeshift_begin = 0
self._timeshift_end = 0
self._program_begin = 0
self._program_end = 0
self._duration = 0
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775fd8c>}
nname: 70
n 70(None)[]:
	i: 15(), 23()
	o: 

nname: 23
n 23(None)[res = min(100, max(0, (val - self._program_begin) * 100.0 / self._duration))
return res
]:
	i: 0(f)
	o: 70()

nname: 15
n 15(None)[return 0
]:
	i: 0(t)
	o: 70()

nname: 0
n 0(self._duration == 0)[]:
	i: 
	o: 15(t), 23(f)

nname: 0
n 0(None)[if self._duration == 0:
	return 0
else:
	res = min(100, max(0, (val - self._program_begin) * 100.0 / self._duration))
	return res
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775fdcc>}
nname: 0
n 0(None)[return self.compute_pos(self._direct)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775f9cc>}
nname: 0
n 0(None)[return self.compute_pos(self._live)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775f9ec>}
nname: 0
n 0(None)[return self.compute_pos(self._timeshift_begin)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775f94c>}
nname: 0
n 0(None)[return self.compute_pos(self._timeshift_end)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775fa2c>}
nname: 63
n 63(None)[]:
	i: 0(AL), 62()
	o: 

nname: 62
n 62(None)[]:
	i: 3(AF), 22()
	o: 63()

nname: 22
n 22(None)[for bar in self.get_list_obj_by_name(self._bar_name):
new_size = self.compute_bar_width()
bar.resize(width=int_to_percent(new_size))
]:
	i: 3(for)
	o: 62()

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 22(for), 62(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 63(AL)

nname: 63
n 63(None)[]:
	i: 22()
	o: 

nname: 22
n 22(None)[for bar in self.get_list_obj_by_name(self._bar_name):
	new_size = self.compute_bar_width()
	bar.resize(width=int_to_percent(new_size))
]:
	i: 0(for)
	o: 63()

nname: 0
n 0(None)[]:
	i: 
	o: 22(for)

nname: 63
n 63(None)[]:
	i: 0()
	o: 

nname: 0
n 0(None)[for bar in self.get_list_obj_by_name(self._bar_name):
	new_size = self.compute_bar_width()
	bar.resize(width=int_to_percent(new_size))
]:
	i: 
	o: 63()

nname: 0
n 0(None)[for bar in self.get_list_obj_by_name(self._bar_name):
	new_size = self.compute_bar_width()
	bar.resize(width=int_to_percent(new_size))
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775fc2c>}
nname: 63
n 63(None)[]:
	i: 0(AL), 62()
	o: 

nname: 62
n 62(None)[]:
	i: 3(AF), 22()
	o: 63()

nname: 22
n 22(None)[for indicator in self.get_list_obj_by_name(self._indicator_name):
live_pos = self.compute_live_pos()
indicator.move(hcenter=int_to_percent(live_pos))
]:
	i: 3(for)
	o: 62()

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 22(for), 62(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 63(AL)

nname: 63
n 63(None)[]:
	i: 22()
	o: 

nname: 22
n 22(None)[for indicator in self.get_list_obj_by_name(self._indicator_name):
	live_pos = self.compute_live_pos()
	indicator.move(hcenter=int_to_percent(live_pos))
]:
	i: 0(for)
	o: 63()

nname: 0
n 0(None)[]:
	i: 
	o: 22(for)

nname: 63
n 63(None)[]:
	i: 0()
	o: 

nname: 0
n 0(None)[for indicator in self.get_list_obj_by_name(self._indicator_name):
	live_pos = self.compute_live_pos()
	indicator.move(hcenter=int_to_percent(live_pos))
]:
	i: 
	o: 63()

nname: 0
n 0(None)[for indicator in self.get_list_obj_by_name(self._indicator_name):
	live_pos = self.compute_live_pos()
	indicator.move(hcenter=int_to_percent(live_pos))
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775fbcc>}
nname: 101
n 101(None)[]:
	i: 0(AL), 100()
	o: 

nname: 100
n 100(None)[]:
	i: 3(AF), 22()
	o: 101()

nname: 22
n 22(None)[for timeshift_bar in self.get_list_obj_by_name(self._timeshift_bar_name):
new_pos = self.compute_timeshift_begin()
new_size = self.compute_timeshift_end() - new_pos
timeshift_bar.move(left=int_to_percent(new_pos))
timeshift_bar.resize(width=int_to_percent(new_size))
]:
	i: 3(for)
	o: 100()

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 22(for), 100(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 101(AL)

nname: 101
n 101(None)[]:
	i: 22()
	o: 

nname: 22
n 22(None)[for timeshift_bar in self.get_list_obj_by_name(self._timeshift_bar_name):
	new_pos = self.compute_timeshift_begin()
	new_size = self.compute_timeshift_end() - new_pos
	timeshift_bar.move(left=int_to_percent(new_pos))
	timeshift_bar.resize(width=int_to_percent(new_size))
]:
	i: 0(for)
	o: 101()

nname: 0
n 0(None)[]:
	i: 
	o: 22(for)

nname: 101
n 101(None)[]:
	i: 0()
	o: 

nname: 0
n 0(None)[for timeshift_bar in self.get_list_obj_by_name(self._timeshift_bar_name):
	new_pos = self.compute_timeshift_begin()
	new_size = self.compute_timeshift_end() - new_pos
	timeshift_bar.move(left=int_to_percent(new_pos))
	timeshift_bar.resize(width=int_to_percent(new_size))
]:
	i: 
	o: 101()

nname: 0
n 0(None)[for timeshift_bar in self.get_list_obj_by_name(self._timeshift_bar_name):
	new_pos = self.compute_timeshift_begin()
	new_size = self.compute_timeshift_end() - new_pos
	timeshift_bar.move(left=int_to_percent(new_pos))
	timeshift_bar.resize(width=int_to_percent(new_size))
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775fc8c>}
nname: 0
n 0(None)[self.set(**value)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775fa0c>}
nname: 256
n 256(None)[return None
]:
	i: 208(), 242(), 255(AE)
	o: 

nname: 242
n 242(None)[DEBUG()
]:
	i: 0(except)
	o: 256()

nname: 208
n 208(None)[self._set_bar()
self._set_timeshift()
self._set_indicator()
]:
	i: 194(), 207()
	o: 256()

nname: 207
n 207(None)[]:
	i: 182(f)
	o: 208()

nname: 194
n 194(None)[self._live = live
]:
	i: 182(t)
	o: 208()

nname: 182
n 182(live is not None)[]:
	i: 168(), 181()
	o: 194(t), 207(f)

nname: 181
n 181(None)[]:
	i: 156(f)
	o: 182()

nname: 168
n 168(None)[self._direct = direct
]:
	i: 156(t)
	o: 182()

nname: 156
n 156(direct is not None)[]:
	i: 133(), 146()
	o: 168(t), 181(f)

nname: 146
n 146(None)[self._timeshift_end = 0
]:
	i: 121(f)
	o: 156()

nname: 133
n 133(None)[self._timeshift_end = timeshift_end
]:
	i: 121(t)
	o: 156()

nname: 121
n 121(timeshift_end is not None)[]:
	i: 98(), 111()
	o: 133(t), 146(f)

nname: 111
n 111(None)[self._timeshift_begin = 0
]:
	i: 67(f)
	o: 121()

nname: 98
n 98(None)[self._timeshift_begin = timeshift_begin
]:
	i: 67(t)
	o: 121()

nname: 67
n 67(timeshift_begin is not None)[self._duration = self._program_end - self._program_begin
]:
	i: 53(), 66()
	o: 98(t), 111(f)

nname: 66
n 66(None)[]:
	i: 41(f)
	o: 67()

nname: 53
n 53(None)[self._program_end = program_end
]:
	i: 41(t)
	o: 67()

nname: 41
n 41(program_end is not None)[]:
	i: 27(), 40()
	o: 53(t), 66(f)

nname: 40
n 40(None)[]:
	i: 3(f)
	o: 41()

nname: 27
n 27(None)[self._program_begin = program_begin
]:
	i: 3(t)
	o: 41()

nname: 3
n 3(program_begin is not None)[timeshift_has_changed = False
program_has_changed = False
]:
	i: 0(try)
	o: 27(t), 40(f)

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 242(except)

nname: 256
n 256(None)[return None
]:
	i: 182(), 242()
	o: 

nname: 242
n 242(None)[except:
	DEBUG()
]:
	i: 0()
	o: 256()

nname: 182
n 182(None)[if live is not None:
	self._live = live
self._set_bar()
self._set_timeshift()
self._set_indicator()
]:
	i: 121()
	o: 256()

nname: 121
n 121(None)[if timeshift_end is not None:
	self._timeshift_end = timeshift_end
else:
	self._timeshift_end = 0
if direct is not None:
	self._direct = direct
]:
	i: 41()
	o: 182()

nname: 41
n 41(None)[if program_end is not None:
	self._program_end = program_end
self._duration = self._program_end - self._program_begin
if timeshift_begin is not None:
	self._timeshift_begin = timeshift_begin
else:
	self._timeshift_begin = 0
]:
	i: 0()
	o: 121()

nname: 0
n 0(None)[try:
	timeshift_has_changed = False
	program_has_changed = False
	if program_begin is not None:
		self._program_begin = program_begin
]:
	i: 
	o: 41(), 242()

nname: 256
n 256(None)[return None
]:
	i: 182(), 242()
	o: 

nname: 242
n 242(None)[except:
	DEBUG()
]:
	i: 0()
	o: 256()

nname: 182
n 182(None)[if live is not None:
	self._live = live
self._set_bar()
self._set_timeshift()
self._set_indicator()
]:
	i: 41()
	o: 256()

nname: 41
n 41(None)[if program_end is not None:
	self._program_end = program_end
self._duration = self._program_end - self._program_begin
if timeshift_begin is not None:
	self._timeshift_begin = timeshift_begin
else:
	self._timeshift_begin = 0
if timeshift_end is not None:
	self._timeshift_end = timeshift_end
else:
	self._timeshift_end = 0
if direct is not None:
	self._direct = direct
]:
	i: 0()
	o: 182()

nname: 0
n 0(None)[try:
	timeshift_has_changed = False
	program_has_changed = False
	if program_begin is not None:
		self._program_begin = program_begin
]:
	i: 
	o: 41(), 242()

nname: 256
n 256(None)[return None
]:
	i: 41(), 242()
	o: 

nname: 242
n 242(None)[except:
	DEBUG()
]:
	i: 0()
	o: 256()

nname: 41
n 41(None)[if program_end is not None:
	self._program_end = program_end
self._duration = self._program_end - self._program_begin
if timeshift_begin is not None:
	self._timeshift_begin = timeshift_begin
else:
	self._timeshift_begin = 0
if timeshift_end is not None:
	self._timeshift_end = timeshift_end
else:
	self._timeshift_end = 0
if direct is not None:
	self._direct = direct
if live is not None:
	self._live = live
self._set_bar()
self._set_timeshift()
self._set_indicator()
]:
	i: 0()
	o: 256()

nname: 0
n 0(None)[try:
	timeshift_has_changed = False
	program_has_changed = False
	if program_begin is not None:
		self._program_begin = program_begin
]:
	i: 
	o: 41(), 242()

self.nodes: {0: <unpyclib.structure.node instance at 0xb7767dec>, 256: <unpyclib.structure.node instance at 0xb77675cc>, 41: <unpyclib.structure.node instance at 0xb7767b4c>, 242: <unpyclib.structure.node instance at 0xb77674cc>}
nname: 0
n 0(None)[self._bar_name = bar
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775f98c>}
nname: 0
n 0(None)[self._indicator_name = indicator
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775f92c>}
nname: 0
n 0(None)[self._live = live
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775f80c>}
nname: 0
n 0(None)[self._direct = direct
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775f88c>}
nname: 0
n 0(None)[self._timeshift_bar_name = timeshift
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775f98c>}
nname: 6
n 6(None)[__doc__ = "\n    A Program bar display a progress bar, showing the part of program which has been already buffered (before direct time).\n    The left side of program bar represent the begin of the program, and the right side the end of the program.\n    And one other small progress bar showing the part of timeshifted part of this program, if this bar is undisplayed, player won't be\n    able to reread this part of timeshift.\n    An indicator, is moved over the live time position.\n    "
def __init__(self):
	Container.__init__(self)
	self._bar_name = None
	self._indicator_name = None
	self._timeshift_bar_name = None
	self._live = 0
	self._direct = 100
	self._timeshift_begin = 0
	self._timeshift_end = 0
	self._program_begin = 0
	self._program_end = 0
	self._duration = 0
	return None

def compute_pos(self, val):
	if self._duration == 0:
		return 0
	else:
		res = min(100, max(0, (val - self._program_begin) * 100.0 / self._duration))
		return res

def compute_bar_width(self):
	return self.compute_pos(self._direct)

def compute_live_pos(self):
	return self.compute_pos(self._live)

def compute_timeshift_begin(self):
	return self.compute_pos(self._timeshift_begin)

def compute_timeshift_end(self):
	return self.compute_pos(self._timeshift_end)

def _set_bar(self):
	for bar in self.get_list_obj_by_name(self._bar_name):
		new_size = self.compute_bar_width()
		bar.resize(width=int_to_percent(new_size))

def _set_indicator(self):
	for indicator in self.get_list_obj_by_name(self._indicator_name):
		live_pos = self.compute_live_pos()
		indicator.move(hcenter=int_to_percent(live_pos))

def _set_timeshift(self):
	for timeshift_bar in self.get_list_obj_by_name(self._timeshift_bar_name):
		new_pos = self.compute_timeshift_begin()
		new_size = self.compute_timeshift_end() - new_pos
		timeshift_bar.move(left=int_to_percent(new_pos))
		timeshift_bar.resize(width=int_to_percent(new_size))

def update(self, signal, sender, value):
	self.set(**value)

initialize = update
def set(self, live=None, direct=None, timeshift_begin=None, program_begin=None, timeshift_end=None, program_end=None):
	try:
		timeshift_has_changed = False
		program_has_changed = False
		if program_begin is not None:
			self._program_begin = program_begin

def set_bar(self, bar=None):
	self._bar_name = bar

def set_indicator(self, indicator=None):
	self._indicator_name = indicator

def set_live(self, live=None):
	self._live = live

def set_direct(self, direct=None):
	self._direct = direct

def set_timeshift(self, timeshift=None):
	self._timeshift_bar_name = timeshift

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb7755e8c>}
nname: 6
n 6(None)[]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb775554c>}
nname: 0
n 0(None)[ProgramTimeShiftBar.__init__(self)
self._record_bar_name = ''
self._record_begin = 0
self._record_end = 0
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7755eac>}
nname: 0
n 0(None)[self._record_bar_name = record
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7755e4c>}
nname: 119
n 119(None)[self._set_record()
return None
]:
	i: 96(), 109()
	o: 

nname: 109
n 109(None)[self._record_end = 0
]:
	i: 84(f)
	o: 119()

nname: 96
n 96(None)[self._record_end = record_end
]:
	i: 84(t)
	o: 119()

nname: 84
n 84(record_end is not None)[]:
	i: 61(), 74()
	o: 96(t), 109(f)

nname: 74
n 74(None)[self._record_begin = 0
]:
	i: 0(f)
	o: 84()

nname: 61
n 61(None)[self._record_begin = record_begin
]:
	i: 0(t)
	o: 84()

nname: 0
n 0(record_begin is not None)[ProgramTimeShiftBar.set(self, live=live, direct=direct, timeshift_begin=timeshift_begin, program_begin=program_begin, timeshift_end=timeshift_end, program_end=program_end)
]:
	i: 
	o: 61(t), 74(f)

nname: 119
n 119(None)[self._set_record()
return None
]:
	i: 0()
	o: 

nname: 0
n 0(None)[ProgramTimeShiftBar.set(self, live=live, direct=direct, timeshift_begin=timeshift_begin, program_begin=program_begin, timeshift_end=timeshift_end, program_end=program_end)
if record_begin is not None:
	self._record_begin = record_begin
else:
	self._record_begin = 0
if record_end is not None:
	self._record_end = record_end
else:
	self._record_end = 0
]:
	i: 
	o: 119()

nname: 0
n 0(None)[ProgramTimeShiftBar.set(self, live=live, direct=direct, timeshift_begin=timeshift_begin, program_begin=program_begin, timeshift_end=timeshift_end, program_end=program_end)
if record_begin is not None:
	self._record_begin = record_begin
else:
	self._record_begin = 0
if record_end is not None:
	self._record_end = record_end
else:
	self._record_end = 0
self._set_record()
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775fb6c>}
nname: 0
n 0(None)[return self.compute_pos(self._record_begin)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7755dcc>}
nname: 0
n 0(None)[return self.compute_pos(self._record_end)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7755e6c>}
nname: 132
n 132(None)[]:
	i: 0(AL), 131()
	o: 

nname: 131
n 131(None)[]:
	i: 3(AF), 22()
	o: 132()

nname: 22
n 22(None)[for record_bar in self.get_list_obj_by_name(self._record_bar_name):
new_pos = self.compute_record_begin()
new_size = self.compute_record_end() - new_pos
width = min(105 - new_pos, new_size)
record_bar.move(left=int_to_percent(round(new_pos)))
record_bar.resize(width=int_to_percent(round(width)))
]:
	i: 3(for)
	o: 131()

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 22(for), 131(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 132(AL)

nname: 132
n 132(None)[]:
	i: 22()
	o: 

nname: 22
n 22(None)[for record_bar in self.get_list_obj_by_name(self._record_bar_name):
	new_pos = self.compute_record_begin()
	new_size = self.compute_record_end() - new_pos
	width = min(105 - new_pos, new_size)
	record_bar.move(left=int_to_percent(round(new_pos)))
	record_bar.resize(width=int_to_percent(round(width)))
]:
	i: 0(for)
	o: 132()

nname: 0
n 0(None)[]:
	i: 
	o: 22(for)

nname: 132
n 132(None)[]:
	i: 0()
	o: 

nname: 0
n 0(None)[for record_bar in self.get_list_obj_by_name(self._record_bar_name):
	new_pos = self.compute_record_begin()
	new_size = self.compute_record_end() - new_pos
	width = min(105 - new_pos, new_size)
	record_bar.move(left=int_to_percent(round(new_pos)))
	record_bar.resize(width=int_to_percent(round(width)))
]:
	i: 
	o: 132()

nname: 0
n 0(None)[for record_bar in self.get_list_obj_by_name(self._record_bar_name):
	new_pos = self.compute_record_begin()
	new_size = self.compute_record_end() - new_pos
	width = min(105 - new_pos, new_size)
	record_bar.move(left=int_to_percent(round(new_pos)))
	record_bar.resize(width=int_to_percent(round(width)))
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb775f68c>}
nname: 6
n 6(None)[def __init__(self):
	ProgramTimeShiftBar.__init__(self)
	self._record_bar_name = ''
	self._record_begin = 0
	self._record_end = 0

def set_record(self, record=None):
	self._record_bar_name = record

def set(self, live=None, direct=None, timeshift_begin=None, program_begin=None, timeshift_end=None, program_end=None, record_begin=None, record_end=None):
	ProgramTimeShiftBar.set(self, live=live, direct=direct, timeshift_begin=timeshift_begin, program_begin=program_begin, timeshift_end=timeshift_end, program_end=program_end)
	if record_begin is not None:
		self._record_begin = record_begin
	else:
		self._record_begin = 0
	if record_end is not None:
		self._record_end = record_end
	else:
		self._record_end = 0
	self._set_record()
	return None

def compute_record_begin(self):
	return self.compute_pos(self._record_begin)

def compute_record_end(self):
	return self.compute_pos(self._record_end)

def _set_record(self):
	for record_bar in self.get_list_obj_by_name(self._record_bar_name):
		new_pos = self.compute_record_begin()
		new_size = self.compute_record_end() - new_pos
		width = min(105 - new_pos, new_size)
		record_bar.move(left=int_to_percent(round(new_pos)))
		record_bar.resize(width=int_to_percent(round(width)))

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb7755c0c>}
nname: 0
n 0(None)[from __future__ import absolute_import
from wyvas import Container
from peewee.debug import GET_LOGGER, DEBUG
from peewee.formatters import int_to_percent
log = GET_LOGGER(__name__)
class Programbar(Container):
	__doc__ = "\n    A Program bar display a progress bar, showing the part of program which has been already buffered (before direct time).\n    The left side of program bar represent the begin of the program, and the right side the end of the program.\n    And one other small progress bar showing the part of timeshifted part of this program, if this bar is undisplayed, player won't be\n    able to reread this part of timeshift.\n    An indicator, is moved over the live time position.\n    "
	def __init__(self):
		Container.__init__(self)
		self._bar_name = None
		self._indicator_name = None
		self._timeshift_bar_name = None
		self._live = 0
		self._direct = 100
		self._timeshift_begin = 0
		self._timeshift_end = 0
		self._program_begin = 0
		self._program_end = 0
		self._duration = 0
		return None

	def compute_pos(self, val):
		if self._duration == 0:
			return 0
		else:
			res = min(100, max(0, (val - self._program_begin) * 100.0 / self._duration))
			return res

	def compute_bar_width(self):
		return self.compute_pos(self._direct)

	def compute_live_pos(self):
		return self.compute_pos(self._live)

	def compute_timeshift_begin(self):
		return self.compute_pos(self._timeshift_begin)

	def compute_timeshift_end(self):
		return self.compute_pos(self._timeshift_end)

	def _set_bar(self):
		for bar in self.get_list_obj_by_name(self._bar_name):
			new_size = self.compute_bar_width()
			bar.resize(width=int_to_percent(new_size))

	def _set_indicator(self):
		for indicator in self.get_list_obj_by_name(self._indicator_name):
			live_pos = self.compute_live_pos()
			indicator.move(hcenter=int_to_percent(live_pos))

	def _set_timeshift(self):
		for timeshift_bar in self.get_list_obj_by_name(self._timeshift_bar_name):
			new_pos = self.compute_timeshift_begin()
			new_size = self.compute_timeshift_end() - new_pos
			timeshift_bar.move(left=int_to_percent(new_pos))
			timeshift_bar.resize(width=int_to_percent(new_size))

	def update(self, signal, sender, value):
		self.set(**value)

	initialize = update
	def set(self, live=None, direct=None, timeshift_begin=None, program_begin=None, timeshift_end=None, program_end=None):
		try:
			timeshift_has_changed = False
			program_has_changed = False
			if program_begin is not None:
				self._program_begin = program_begin

	def set_bar(self, bar=None):
		self._bar_name = bar

	def set_indicator(self, indicator=None):
		self._indicator_name = indicator

	def set_live(self, live=None):
		self._live = live

	def set_direct(self, direct=None):
		self._direct = direct

	def set_timeshift(self, timeshift=None):
		self._timeshift_bar_name = timeshift



class ProgramTimeShiftBar(Programbar):
	pass

class ProgramRecordTimeShiftBar(ProgramTimeShiftBar):
	def __init__(self):
		ProgramTimeShiftBar.__init__(self)
		self._record_bar_name = ''
		self._record_begin = 0
		self._record_end = 0

	def set_record(self, record=None):
		self._record_bar_name = record

	def set(self, live=None, direct=None, timeshift_begin=None, program_begin=None, timeshift_end=None, program_end=None, record_begin=None, record_end=None):
		ProgramTimeShiftBar.set(self, live=live, direct=direct, timeshift_begin=timeshift_begin, program_begin=program_begin, timeshift_end=timeshift_end, program_end=program_end)
		if record_begin is not None:
			self._record_begin = record_begin
		else:
			self._record_begin = 0
		if record_end is not None:
			self._record_end = record_end
		else:
			self._record_end = 0
		self._set_record()
		return None

	def compute_record_begin(self):
		return self.compute_pos(self._record_begin)

	def compute_record_end(self):
		return self.compute_pos(self._record_end)

	def _set_record(self):
		for record_bar in self.get_list_obj_by_name(self._record_bar_name):
			new_pos = self.compute_record_begin()
			new_size = self.compute_record_end() - new_pos
			width = min(105 - new_pos, new_size)
			record_bar.move(left=int_to_percent(round(new_pos)))
			record_bar.resize(width=int_to_percent(round(width)))



]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb774ec8c>}
from __future__ import absolute_import
from wyvas import Container
from peewee.debug import GET_LOGGER, DEBUG
from peewee.formatters import int_to_percent
log = GET_LOGGER(__name__)
class Programbar(Container):
	__doc__ = "\n    A Program bar display a progress bar, showing the part of program which has been already buffered (before direct time).\n    The left side of program bar represent the begin of the program, and the right side the end of the program.\n    And one other small progress bar showing the part of timeshifted part of this program, if this bar is undisplayed, player won't be\n    able to reread this part of timeshift.\n    An indicator, is moved over the live time position.\n    "
	def __init__(self):
		Container.__init__(self)
		self._bar_name = None
		self._indicator_name = None
		self._timeshift_bar_name = None
		self._live = 0
		self._direct = 100
		self._timeshift_begin = 0
		self._timeshift_end = 0
		self._program_begin = 0
		self._program_end = 0
		self._duration = 0
		return None

	def compute_pos(self, val):
		if self._duration == 0:
			return 0
		else:
			res = min(100, max(0, (val - self._program_begin) * 100.0 / self._duration))
			return res

	def compute_bar_width(self):
		return self.compute_pos(self._direct)

	def compute_live_pos(self):
		return self.compute_pos(self._live)

	def compute_timeshift_begin(self):
		return self.compute_pos(self._timeshift_begin)

	def compute_timeshift_end(self):
		return self.compute_pos(self._timeshift_end)

	def _set_bar(self):
		for bar in self.get_list_obj_by_name(self._bar_name):
			new_size = self.compute_bar_width()
			bar.resize(width=int_to_percent(new_size))

	def _set_indicator(self):
		for indicator in self.get_list_obj_by_name(self._indicator_name):
			live_pos = self.compute_live_pos()
			indicator.move(hcenter=int_to_percent(live_pos))

	def _set_timeshift(self):
		for timeshift_bar in self.get_list_obj_by_name(self._timeshift_bar_name):
			new_pos = self.compute_timeshift_begin()
			new_size = self.compute_timeshift_end() - new_pos
			timeshift_bar.move(left=int_to_percent(new_pos))
			timeshift_bar.resize(width=int_to_percent(new_size))

	def update(self, signal, sender, value):
		self.set(**value)

	initialize = update
	def set(self, live=None, direct=None, timeshift_begin=None, program_begin=None, timeshift_end=None, program_end=None):
		try:
			timeshift_has_changed = False
			program_has_changed = False
			if program_begin is not None:
				self._program_begin = program_begin

	def set_bar(self, bar=None):
		self._bar_name = bar

	def set_indicator(self, indicator=None):
		self._indicator_name = indicator

	def set_live(self, live=None):
		self._live = live

	def set_direct(self, direct=None):
		self._direct = direct

	def set_timeshift(self, timeshift=None):
		self._timeshift_bar_name = timeshift



class ProgramTimeShiftBar(Programbar):
	pass

class ProgramRecordTimeShiftBar(ProgramTimeShiftBar):
	def __init__(self):
		ProgramTimeShiftBar.__init__(self)
		self._record_bar_name = ''
		self._record_begin = 0
		self._record_end = 0

	def set_record(self, record=None):
		self._record_bar_name = record

	def set(self, live=None, direct=None, timeshift_begin=None, program_begin=None, timeshift_end=None, program_end=None, record_begin=None, record_end=None):
		ProgramTimeShiftBar.set(self, live=live, direct=direct, timeshift_begin=timeshift_begin, program_begin=program_begin, timeshift_end=timeshift_end, program_end=program_end)
		if record_begin is not None:
			self._record_begin = record_begin
		else:
			self._record_begin = 0
		if record_end is not None:
			self._record_end = record_end
		else:
			self._record_end = 0
		self._set_record()
		return None

	def compute_record_begin(self):
		return self.compute_pos(self._record_begin)

	def compute_record_end(self):
		return self.compute_pos(self._record_end)

	def _set_record(self):
		for record_bar in self.get_list_obj_by_name(self._record_bar_name):
			new_pos = self.compute_record_begin()
			new_size = self.compute_record_end() - new_pos
			width = min(105 - new_pos, new_size)
			record_bar.move(left=int_to_percent(round(new_pos)))
			record_bar.resize(width=int_to_percent(round(width)))



